﻿using DevTeam;
using System;
using System.Windows.Forms;

namespace ConfExpert.Forms.Depo.Aksesuar
{
    public partial class AksesuarNotuEkle : XPopupForm
    {
        public AksesuarNotuEkle()
        {
            InitializeComponent();
        }

        private void AksesuarNotuEkle_Load(object sender, EventArgs e)
        {
            btnOK.Click += btnOK_Click;
            txtNote.KeyDown += txtNote_KeyDown;
            chkRemove.CheckedChanged += chkRemove_CheckedChanged;
            cmbFatura.SelectedIndexChanged += cmbFatura_SelectedIndexChanged;
            chkRemove.Checked = true;
            txtFatura.Enabled = false;
        }

        void cmbFatura_SelectedIndexChanged(object sender, EventArgs e)
        {
            if(cmbFatura.SelectedIndex==1)
                txtFatura.Enabled = true;
            else
            {
                txtFatura.Enabled = false;
                txtFatura.Text = null;
            }
        }

        void chkRemove_CheckedChanged(object sender, EventArgs e)
        {
            chkUsable.Enabled = chkRemove.Checked;
            if (!chkRemove.Checked)
                chkUsable.Checked = false;
        }

        void txtNote_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                e.SuppressKeyPress = true;
            }
        }

        public string note = string.Empty;
        public bool isPassive = false;
        public bool isUsable = false;
        public int musteriFaturaDurumu;
        public string faturaNo = string.Empty;

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtNote.Text == String.Empty)
            {
                MessageBox.Show("Not alanı boş bırakılamaz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                note = txtNote.Text;
                musteriFaturaDurumu = cmbFatura.SelectedIndex;
                faturaNo = txtFatura.Text;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                isPassive = chkRemove.Checked;
                isUsable = chkUsable.Checked;
            }
        }

    }
}